package com.helloniu.red5.info;

import java.util.ArrayList;

import com.helloniu.red5.Tool;

public class ConferenceInfo {
	public ConferenceInfo() {
	}
	
	public ConferenceInfo(String confID) {
		this.confID = confID;
	}
	
	public void addUser(String userID) {
		userList.add(new UserInfo(userID));
	}
	
	public void addUser(UserInfo uinfo) {
		userList.add(uinfo);
	}
	
	public void removeUser(String uid) {
		UserInfo auinfo = null;
		for(UserInfo uinfo : userList) {
			if(uid.equals(uinfo.userID)) {
				auinfo = uinfo;
				break;
			}
		}
		
		if(auinfo != null) {
			userList.remove(auinfo);	
		}
		
		Tool.o("====remove user: = " + auinfo);
		
	}
	
	public void removeUser(UserInfo uinfo) {
	}
	
	public void updateUser(String userID, BussinessInfo binfo) {
	}
	
	public void updateUser(String userID, BussinessUnit bunit) {
		UserInfo uinfo = getUser(userID);
		uinfo.binfo.upadte(bunit);
	}
	
	public UserInfo getUser(String uid) {
		for(UserInfo uinfo : userList) {
			if(uid.equals(uinfo.userID)) {
				return uinfo;
			}
		}
		
		return null;
	}
	
	public String toString() {
		return userList.toString();
	}
	
    public String confID = null;
    public UserInfo[] users = new UserInfo[0];
    public ArrayList<UserInfo> userList = new ArrayList<UserInfo>();
}
